package com.ljx.recruitment.interview.service.impl.process;

import cn.hutool.core.util.StrUtil;
import cn.hutool.json.JSONUtil;
import com.ljx.recruitment.common.exception.ApiException;
import com.ljx.recruitment.interview.constant.JobConstant;
import com.ljx.recruitment.interview.domain.entity.Deliver;
import com.ljx.recruitment.interview.domain.vo.req.DeliverSubmitReq;
import com.ljx.recruitment.interview.enums.DeliverOptionEnum;
import com.ljx.recruitment.interview.enums.DeliverStatusEnum;
import com.ljx.recruitment.interview.enums.JobBaseProcessEnum;
import com.ljx.recruitment.interview.service.DeliverProcess;
import com.ljx.recruitment.interview.service.DeliverService;
import com.ljx.recruitment.interview.typehandler.details.DeliverDetails;
import com.ljx.recruitment.mq.dto.DeliverEmailObjDto;
import com.ljx.recruitment.mq.dto.MqTransferDto;
import com.ljx.recruitment.mq.enums.MQTypeEnum;
import com.ljx.recruitment.mq.producer.RabbitMQProducer;
import com.ljx.recruitment.user.enums.EmailTypeEnum;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.Map;
import java.util.Objects;

/**
 * @Author: LiJunXi
 * @Description:
 * @Date: 2025-01-01  16:19
 */
@Service
public class SalvageProcess implements DeliverProcess {
    @Autowired
    private DeliverService deliverService;

    @Autowired
    private RabbitMQProducer rabbitMQProducer;

    @Override
    public String getTitle(Deliver deliver) {
        return DeliverStatusEnum.OFFER.getTitle() + "_" + deliver.getBatch();
    }

    @Override
    public void handleDeliver(Deliver deliver, DeliverSubmitReq req, Integer option) {
        checkParams(deliver.getDeliverStatus());
        req = new DeliverSubmitReq();
        Map<String, String> map = new HashMap<>();
        req.setExtObject(map);
        afterHandler(deliver, req, option);
    }

    private void checkParams(Integer deliverStatus) {

    }

    private void afterHandler(Deliver deliver, DeliverSubmitReq req, Integer option) {
        rabbitMQProducer.sendMQMsg(new MqTransferDto(MQTypeEnum.EMAIL.getKey(),
                new DeliverEmailObjDto(EmailTypeEnum.SALVAGE.getKey(), option,
                        deliver.getId(), req.getExtObject())));
    }
}
